#ifndef _KAFKA_PRODUCER_H_H_H
#define _KAFKA_PRODUCER_H_H_H

#include "kafka_eventcb.hpp"

#include <librdkafka/rdkafkacpp.h>

class KafkaProducer
{
public:
    KafkaProducer(const std::string &brokers);
    ~KafkaProducer();

public:
    /**
     * Kafka 生产者初始化
     * @param brokers 地址
     */
    bool init(bool               with_sasl   = false,
              const std::string &protocol    = "",
              const std::string &mechanisms  = "",
              const std::string &username    = "",
              const std::string &password    = "",
              bool               with_ssl    = false,
              const std::string &ca_location = "");
    bool produce(std::string topic, const std::string &message);
    bool produce(std::string topic, void *payload, size_t len);

private:
    std::string        m_brokers;
    RdKafka::Producer *m_producer;
    RdKafkaEventCb    *m_eventcb;
};

#endif
